<template>
  <div class="eventRecord">
    <div class="searchDiv">
      <Form :model="searchItem" :label-width="80">
        <Row :gutter="10">
          <Col span="6">
            <FormItem label="电站">
              <Select v-model="searchItem.powerStation" clearable filterable @on-change="getHd">
                <Option
                  v-for="(item, index) in powerStationList"
                  :value="item"
                  :key="index"
                >{{ item }}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="HD编号">
              <Select
                v-model="searchItem.hdNumber"
                clearable
                filterable
                :disabled="HBnumberList.length == 0"
                @on-change="getJz"
              >
                <Option v-for="(item, index) in HBnumberList" :value="item" :key="index">{{ item }}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="机组编号">
              <Select
                v-model="searchItem.aircrewNumber"
                clearable
                filterable
                :disabled="JZnumberList.length == 0"
              >
                <Option v-for="(item, index) in JZnumberList" :value="item" :key="index">{{ item }}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="机型">
                <Input v-model="searchItem.model" placeholder="请输入"></Input>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="功能位置">
              <Input v-model="searchItem.location" placeholder="请输入"></Input>
            </FormItem>
          </Col>
           <Col span="6">
            <FormItem label="记录人">
              <Select  v-model="searchItem.recordName" label-in-value clearable filterable>
                          <Option v-for="(item, index) in peopleList" :value="item.trueName" :key="index">{{item.trueName}}</Option>
                </Select>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="发生时间">
              <DatePicker
                type="datetimerange"
                placeholder="请选择"
                style="width: 100%"
                @on-change="handleChengeStartTime0"
              ></DatePicker>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="原因分类">
                <Select v-model="searchItem.reasonCatory" clearable filterable>
                  <Option v-for="(item, index) in reasonCatoryList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
              </Select>

            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="专业分类">
                <Select v-model="searchItem.professionCatory" clearable filterable>
                  <Option v-for="(item, index) in professionCatoryList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="6">
            <FormItem label="记录时间">
              <DatePicker
                type="datetimerange"
                placeholder="请选择"
                style="width: 100%"
                @on-change="handleChangeRecordTime"
              ></DatePicker>
            </FormItem>
          </Col>
          <Col span="12">
            <Button type="primary" @click="searchItem.pageNo=1;search()" class="marRight">查询</Button>
            <Button type="success" class="marRight" @click="add">新增事件记录</Button>
            <Button type="primary" class="marRight" @click="down">导出Excel</Button>
             <Upload style="display:inline-block" :headers='fileheader' :on-success='fileSuccess' :show-upload-list='false'
                :action="apihost+'/admin-api/admins/eventRecord/upload'">
                <Button  type="info">批量导入</Button>
            </Upload>
          </Col>
        </Row>
      </Form>
    </div>
    <Table :loading="loading" border :columns="columns" :data="tableData"></Table>
    <Page show-total :total="total" show-elevator :current="searchItem.pageNo" :page-size='searchItem.pageSize' @on-change='pageChange'  style="margin:20px auto;text-align:center"/>

    <!-- 新增弹窗开始 -->
    <Modal :mask-closable="false" v-model="modal1" :title="title1" width="800" @on-ok="ok">
      <div class="baseTitle">基本信息</div>
           <Form :label-width="120">
             <Row :gutter="10" class="xzjz">
                 <Col span="12">
                    <FormItem :model="formItem" label="电站：">
                        <Select v-model="formItem.powerStation" clearable filterable @on-change="getHd">
                        <Option v-for="(item, index) in powerStationList" :value="item" :key="index">{{item}}</Option>
                    </Select>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="HD编号：">
                     <Select v-model="formItem.hdNumber" clearable filterable :disabled="HBnumberList.length==0" @on-change="getJz">
                        <Option v-for="(item, index) in HBnumberList" :value="item" :key="index">{{item}}</Option>
                    </Select>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="机组编号：">
                        <Select v-model="formItem.aircrewNumber" clearable filterable :disabled="JZnumberList.length==0" @on-change="getMode">
                          <Option v-for="(item, index) in JZnumberList" :value="item" :key="index">{{item}}</Option>
                      </Select>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="型号：">
                      {{formItem.model}}
                      <!-- <Input v-model="formItem.model" disabled placeholder="自动获取"></Input> -->
                    </FormItem>
                  </Col>
             </Row>
           </Form>
           <div class="baseTitle">事件信息</div>
           <Form :label-width="120">
             <Row :gutter="10" class="xzjz">
                <Col span="24">
                    <FormItem label="事件标题：">
                      <Input v-model="formItem.title" :maxlength="20" placeholder="请输入"></Input>
                    </FormItem>
                  </Col>
                 <Col span="12">
                    <FormItem label="功能位置：">
                      <Input v-model="formItem.location" :maxlength="20" placeholder="请输入"></Input>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="发生时间：">
                      <DatePicker
                        type="datetime"
                        v-model="formItem.startTime"
                        placeholder="请选择"
                        style="width: 100%"
                        @on-change="handleChengeStartTime"
                      ></DatePicker>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="原因分析：">
                      <Input v-model="formItem.reasonAnalyze" :maxlength="20" placeholder="请输入"></Input>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="原因分类：">
                       <Select v-model="formItem.reasonCatory" clearable filterable>
                          <Option v-for="(item, index) in reasonCatoryList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
                      </Select>


                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="专业分类：">
                        <Select v-model="formItem.professionCatory" clearable filterable>
                          <Option v-for="(item, index) in professionCatoryList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
                      </Select>

                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="子系统：">
                        <Select v-model="formItem.subsystem" clearable filterable>
                          <Option v-for="(item, index) in subSystemList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
                      </Select>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="大修/日常：">
                      <Select v-model="formItem.everyday" clearable filterable>
                          <Option v-for="(item, index) in everydayList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
                      </Select>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="问题进度：">
                      <InputNumber
                      style="width:100%"
            :max="100" :min="0"
            v-model="formItem.issueProgress"
            :formatter="value => `${value}%`"
            :parser="value => value.replace('%', '')"></InputNumber>
                      <!-- <Input v-model="formItem.issueProgress" placeholder="请输入"></Input> -->
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="影响WANO时间：">
                      <InputNumber  :maxlength="10" style="width:100%;" v-model="formItem.effectWano"></InputNumber>
                      <!-- <Input v-model="formItem.effectWano" type="number" :maxlength="10" placeholder="请输入"></Input> -->
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="IO1：">
                      <Input v-model="formItem.io1" :maxlength="10" placeholder="请输入"></Input>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="IOER：">
                       <Select v-model="formItem.ioer" clearable filterable>
                          <Option v-for="(item, index) in ioerList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
                      </Select>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="后果：">
                      <Select v-model="formItem.consequence" clearable filterable>
                          <Option v-for="(item, index) in consequenceList" :value="item.displayName" :key="index">{{item.displayName}}</Option>
                      </Select>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="问题分级：">
                       <Select v-model="formItem.questionLvDictId" clearable filterable  @on-change='problemChange'>
                          <Option v-for="(item, index) in ProblemList" :value="item.id" :key="index">{{item.displayName}}</Option>
                      </Select>
                    </FormItem>
                  </Col>
             </Row>
           </Form>
           <div class="baseTitle">事件描述</div>
           <Form :label-width="120">
             <FormItem label="事件描述：">
                      <Input v-model="formItem.description" :maxlength="200" type="textarea" placeholder="请输入"></Input>
              </FormItem>
              <FormItem label="风险分析：">
                      <Input v-model="formItem.ventureAnalysis" :maxlength="200" type="textarea" placeholder="请输入"></Input>
              </FormItem>
              <FormItem label="应对措施：">
                      <Input v-model="formItem.solutions" :maxlength="200" type="textarea" placeholder="请输入"></Input>
              </FormItem>
           </Form>
           <div class="baseTitle">填报信息</div>
            <Form :label-width="120">
             <Row :gutter="10" class="xzjz">
                  <Col span="12">
                    <FormItem label="记录人：">
                     <!-- <Select @on-change="jiluName" v-model="formItem.recordId" label-in-value clearable filterable>
                          <Option v-for="(item, index) in peopleList" :value="item.id" :key="index">{{item.trueName}}</Option>
                      </Select> -->
                       <Input v-model="recordName" disabled placeholder="请输入"></Input>
                    </FormItem>
                  </Col>
                  <Col span="12">
                    <FormItem label="记录时间：">
                      <!-- <DatePicker
                        type="datetime"
                        v-model="formItem.recordTime"
                        placeholder="记录时间"
                        @on-change="handleChangeRecordTime"
                        style="width: 100%"
                      ></DatePicker> -->
                       <Input v-model="recordTime" disabled placeholder="请输入"></Input>
                    </FormItem>
                  </Col>
           </Row>
           </Form>
           <div slot="footer">
            <Button type="primary" :loading="btnClick" @click="ok">确定</Button>
            <Button @click="addWtgz">添加至问题跟踪</Button>
            <Button @click="modal1=false">取消</Button>
           </div>
    </Modal>
    <Modal :mask-closable="false" v-model="modal2" width="360" class-name="vertical-center-modal" @on-ok="remove(delIndex)">
        <p slot="header" style="color:#f60;text-align:center">
            <Icon type="ios-information-circle"></Icon>
            <span>确认删除</span>
        </p>
        <div style="text-align:center">
            <p>确认删除此数据么？</p>
        </div>
    </Modal>
    <!-- 新增弹窗结束 -->
  </div>
</template>

<script>
import { getToken } from '@/libs/util'
import {
  addEvent,
  searchEvent,
  removeEvent,
  updateEvent,
  addIssure,
  eventRecordDown
} from '@/api/problem'
import {
  getSelectOption,
  getAllPeople,
  getTime,getAllEqu
} from '@/api/select'
export default {
  data () {
    return {
      btnClick:false,
      fileheader: {
        Authorization: 'Bearer ' + (getToken() ? getToken() : '')
      },
      recordName: localStorage.getItem('recordUserName'),
        recordId:localStorage.getItem('recordUserId'),
        recordTime:getTime(),
        loading:true,
      total: 0,
      delIndex: 0,
      modal2: false,
      modal1: false,
      title1: '新增事件记录',
      peopleList:[],
      loading1: false,
      powerStationList: '',
      loading2: false,
       allEquList: [],
      allEquList2: [],
      HBnumberList: '',
      loading3: false,
      JZnumberList: '',
      reasonCatoryList: [],
      loading4: false,
      professionCatoryList: [],
      loading5: false,
      subSystemList: [],
      loading6: false,
      everydayList: [],
      loading7: false,
      ioerList: [],
      loading8: false,
      consequenceList: [],
      loading9: false,
      ProblemList: [],
      loading10: false,
      ProblemListIndex:'',
      searchItem: {
        pageNo: 1,
        pageSize: 10
      },
      formItem: {

      },
      columns: [
        {
          type: 'index',
          width: 70,
          title: '序号',
          align: 'center',
          fixed: 'left'
        },
        {
          title: '电站',
          key: 'powerStation',
          width: 100
        },
        {
          title: 'HD编号',
          key: 'hdNumber',
          width: 100
        },
        {
          title: '机组编号',
          key: 'aircrewNumber',
          width: 100
        },
        {
          title: '功能位置',
          key: 'location',
          width: 100
        },
        {
          title: '机型',
          key: 'model',
          width: 100
        },
        {
          title: '发生时间',
          key: 'startTime',
          width: 150
        },
        {
          title: '事件描述',
          key: 'description',
          width: 150
        },
        {
          title: '原因分类',
          key: 'reasonCatory',
          width: 100
        },
        {
          title: '专业分类',
          key: 'professionCatory',
          width: 100
        },
        {
          title: '子系统',
          key: 'subsystem',
          width: 100
        },
        {
          title: '大修/日常',
          key: 'everyday',
          width: 100
        },
        {
          title: '问题进度',
          key: 'issueProgress',
          width: 100
        },
        {
          title: '记录人',
          key: 'recordName',
          width: 100
        },
        {
          title: '记录时间',
          key: 'recordTime',
          width: 150
        },
        {
          title: '操作',
          key: 'action',
          width: 150,
          align: 'center',
          fixed: 'right',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.edit(JSON.stringify(params));
                    }
                  }
                },
                '编辑'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'error',
                    size: 'small'
                  },
                  on: {
                    click: () => {
                      this.openDel(params.row.id)
                    }
                  }
                },
                '删除'
              )
            ])
          }
        }
      ],
      tableData: [
      ]
    }
  },
  methods: {
  //  jiluName(e){
  //     this.formItem.recordName=e.label
  //   },
  fileSuccess (response, file, fileList) {
      this.$Message.info('导入成功')
      this.search();
    },
    down(){
      eventRecordDown(this.searchItem).then(res => {
         const blob = new Blob([res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;'});

        const ie = navigator.userAgent.match(/MSIE\s([\d.]+)/),
            ie11 = navigator.userAgent.match(/Trident\/7.0/) && navigator.userAgent.match(/rv:11/),
            ieEDGE = navigator.userAgent.match(/Edge/g),
            ieVer = (ie ? ie[1] : (ie11 ? 11 : (ieEDGE ? 12 : -1)));
        console.log('ie:' + ie);
        console.log('ieVer:' + ieVer);
        if (ie && ieVer < 10) {
            this.message.error('No blobs on IE<10');
            return;
        }
        if (ieVer > -1) {
            window.navigator.msSaveBlob(blob, '事件记录.xlsx');
        } else {
            const url = window.URL.createObjectURL(blob);
            let link = document.createElement('a');
            link.setAttribute('href', url);
            link.setAttribute('download', '事件记录.xlsx');
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        }

        // const blob = new Blob([res]);//处理文档流
        //   const fileName = '事件记录.xlsx';
        //   const elink = document.createElement('a');
        //   elink.download = fileName;
        //   elink.style.display = 'none';
        //   elink.href = URL.createObjectURL(blob);
        //   document.body.appendChild(elink);
        //   elink.click();
        //   URL.revokeObjectURL(elink.href); // 释放URL 对象
        //   document.body.removeChild(elink);
      })
    },
    pageChange (e) {
      this.searchItem.pageNo = e
      console.log(this.searchItem.pageNo, '页码')
      this.search()
    },
    handleChengeStartTime (e) {
      this.formItem.startTime = e
    },
     handleChengeStartTime0 (e) {
      this.searchItem.startTime = e[0];
      this.searchItem.endTime = e[1];
    },
    handleChangeRecordTime (e) {
      this.searchItem.startRecordTime = e[0];
      this.searchItem.endRecordTime = e[1];
    },
   //获取所有人员
    getAllPeople(){
      getAllPeople(
        null
      ).then(res => {
        this.peopleList = res.data
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    },
     // 获取电站类型列表
    // powerStation () {
    //   getSelectOption(
    //     {
    //       code: 'dianzhan'
    //     }
    //   ).then(res => {
    //     this.powerStationList = res.data
    //   }).catch(err => {
    //     console.error('err>' + JSON.stringify(err))
    //   })
    // },
    // HBnumber () {
    //   getSelectOption(
    //     {
    //       code: 'hd_code'
    //     }
    //   ).then(res => {
    //     this.HBnumberList = res.data
    //   }).catch(err => {
    //     console.error('err>' + JSON.stringify(err))
    //   })
    // },
    // JZnumber () {
    //   getSelectOption(
    //     {
    //       code: 'jizu_code'
    //     }
    //   ).then(res => {
    //     this.JZnumberList = res.data
    //   }).catch(err => {
    //     console.error('err>' + JSON.stringify(err))
    //   })
    // },

    // reason_catory_key getReasonCatory reasonCatoryList
    getReasonCatory () {
      getSelectOption({ code: 'reason_catory_key' }).then(res => {
        console.log('getReasonCatory: ', res)
        this.reasonCatoryList = res.data
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    },

    // profession_catory_key getProfessionCatory professionCatoryList
    getProfessionCatory () {
      getSelectOption({ code: 'profession_catory_key' }).then(res => {
        console.log('getProfessionCatory: ', res)
        this.professionCatoryList = res.data
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    },

    // sub_system_key getSubSystem subSystemList
    getSubSystem () {
      getSelectOption({ code: 'sub_system_key' }).then(res => {
        this.subSystemList = res.data
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    },

    // everyday_key getEveryday everydayList
    getEveryday () {
      getSelectOption({ code: 'everyday_key' }).then(res => {
        console.log('getEveryday: ', res)
        this.everydayList = res.data
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    },
    // ioer_key  getIoer ioerList
    getIoer () {
      getSelectOption({ code: 'ioer_key' }).then(res => {
        console.log('getIoer: ', res)
        this.ioerList = res.data
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    },
    // consequence_key getConsequence consequenceList
    getConsequence () {
      getSelectOption({ code: 'consequence_key' }).then(res => {
        console.log('getConsequence: ', res)
        this.consequenceList = res.data
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
      })
    },
    //获取问题分级
    getProblem () {
      getSelectOption(
        {
          code: 'problemGrade'
        }
      ).then(res => {
        this.ProblemList = res.data;
      }).catch(err => {
        console.error('err>' + JSON.stringify(err));
      })
    },
    problemChange(e){
      var arry=this.ProblemList.filter(item => item.id==e)
       this.formItem.questionLvDisplayName=arry[0].displayName
       this.formItem.questionLvValue=arry[0].value
    },
    remove (id) {
      let obj = {
        id: id
      }
      removeEvent(obj).then(res => {
        if (res.code == 0) {
          this.$Message.info('删除成功')
          this.searchItem.pageNo=1
          this.search()
        } else {
          this.$Message.info(res.message)
        }
      }).catch(err => {
        console.error('err>' + JSON.stringify(err))
        this.loading3 = false
      })
    },
    openDel (index) {
      this.modal2 = true
      this.delIndex = index
      // this.remove(params.index);
    },
    add () {
      this.title1 = '新增事件记录'
      this.modal1 = true
      this.formItem={
        issueProgress:0,
        effectWano:0
      }
    },
    edit (params) {
      this.title1 = '编辑事件记录'
      this.formItem = JSON.parse(params).row
      this.modal1 = true

      this.allEquList2 = this.allEquList.filter(item => item.powerStation == this.formItem.powerStation);
      let arr2 = this.allEquList2.map(function(item) {
        return item.hdNumber;
      });
      this.HBnumberList = [...new Set(arr2)];

      let arr3 = this.allEquList2.filter(item => item.hdNumber == this.formItem.hdNumber);
      let arr4 = arr3.map(function(item) {
        return item.aircrewNumber;
      });
      this.JZnumberList = [...new Set(arr4)];
    },
    ok () {
      this.btnClick=true;
      this.formItem.recordName=this.recordName;
      this.formItem.recordId=this.recordId;
      this.formItem.recordTime=this.recordTime;
      if (this.title1 == '新增事件记录') {
        addEvent(this.formItem).then((res) => {
          console.log('data：', this.formItem)
          console.log('add success： ', res)
          if (res.code == 0) {
            this.$Message.info('新增成功')
            this.modal1 = false;
            this.search()
            this.btnClick=false
          } else {
            this.$Message.info(res.message)
          }
        }).catch(err => {
          console.error('err>' + JSON.stringify(err))
          this.loading3 = false
          this.btnClick=false
        })
      } else {
        this.formItem.startTime=this.timeFormat(this.formItem.startTime)
       // this.formItem.recordTime=this.timeFormat(this.formItem.recordTime)
        updateEvent(this.formItem).then(res => {
          console.log(res, this.formItem)
          if (res.code == 0) {
            this.$Message.info('修改成功')
            this.search();
            this.modal1 = false;
            this.btnClick=false
          } else {
            this.$Message.info(res.message)
            this.btnClick=false
          }
        }).catch(err => {
          console.error('err>' + JSON.stringify(err))
        })
      }
    },
    addWtgz () {
      // this.formItem.recordName=this.recordName;
      // this.formItem.recordId=this.recordId;
      // this.formItem.recordTime=this.recordTime;
      // if (this.title1 == '新增事件记录') {
      //   addIssure(this.formItem).then((res) => {
      //     console.log('data：', this.formItem)
      //     console.log('add success： ', res)
      //     if (res.code == 0) {
      //       this.$Message.info('新增成功')
      //       this.search()
      //     } else {
      //       this.$Message.info(res.message)
      //     }
      //   }).catch(err => {
      //     console.error('err>' + JSON.stringify(err))
      //     this.loading3 = false
      //   })
      // } else {
      //   this.formItem.startTime=this.timeFormat(this.formItem.startTime)
      //   this.formItem.recordTime=this.timeFormat(this.formItem.recordTime)
      //   addIssure(this.formItem).then(res => {
      //     console.log(res, this.formItem)
      //     if (res.code == 0) {
      //       this.$Message.info('新增成功')
      //       this.search()
      //     } else {
      //       this.$Message.info(res.message)
      //     }
      //   }).catch(err => {
      //     console.error('err>' + JSON.stringify(err))
      //   })
      // }
      this.$router.push(
        {
          path:'/problem/tefectTracking',
          query:{
            open:true,
            location:this.formItem.location,
            issue:this.formItem.title,
            source:"事件记录",
            description:this.formItem.description,
            reasonAnalyze:this.formItem.ventureAnalysis
          }
        }
      )
      this.modal1=false;
    },
    timeFormat (time) {
      if(time instanceof Date==false){
        return time
      }
                const dateTime = new Date(time)
                const year = dateTime.getFullYear()
                const month = this.addZero(dateTime.getMonth() + 1)
                const date = this.addZero(dateTime.getDate())
                const hour = this.addZero(dateTime.getHours())
                const minute = this.addZero(dateTime.getMinutes())
                const second = this.addZero(dateTime.getSeconds())
                return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second
            },
            addZero (v) {
                return v < 10 ? '0' + v : v
            },
    search () {
      console.log(this.searchItem)
      searchEvent(this.searchItem).then(res => {
        console.log('get search:', res)

        if (res.code == 0) {
          this.tableData = res.data.list

          this.total = res.data.total
          this.loading=false
        } else {
          this.$Message.info(res.message)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    getAllEqument() {
      getAllEqu(null).then(res => {
        this.allEquList = res.data;
        let arr = res.data.map(function(item) {
          return item.powerStation;
        });
        this.powerStationList = [...new Set(arr)];
      });
    },
    getHd(e) {
      this.JZnumberList = [];
      this.allEquList2 = this.allEquList.filter(item => item.powerStation == e);
      let arr2 = this.allEquList2.map(function(item) {
        return item.hdNumber;
      });
      this.HBnumberList = [...new Set(arr2)];
    },
    getJz(e) {
      let arr = this.allEquList2.filter(item => item.hdNumber == e);
      let arr2 = arr.map(function(item) {
        return item.aircrewNumber;
      });
      this.JZnumberList = [...new Set(arr2)];
    },
    getMode(e){
      let arr = this.allEquList2.filter(item => item.hdNumber == this.formItem.hdNumber&&item.aircrewNumber == e)
      this.formItem.model=arr[0].model
    }
  },
  mounted () {
    this.getAllEqument();
    this.getReasonCatory();this.getProfessionCatory();this.getSubSystem();this.getEveryday();this.getIoer();this.getConsequence();this.getProblem();
    this.getAllPeople();
    this.search()
  }
}
</script>

<style lang="less">
.eventRecord {
  background: #fff;
  height: 100%;
  padding: 15px;
  font-size: 14px;
  .searchDiv {
    .marRight {
      margin-right: 15px;
    }
  }
  .ivu-form-item {
    margin-bottom: 15px;
  }
}
.baseTitle {
    font-weight: bold;
    font-size:16px;
    margin-bottom:10px;
  }
 .xzjz  {
   .ivu-form-item {
    margin-bottom: 10px;
  }
 }

</style>
